package Srevet_;

import javax.sound.sampled.Port;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

import static Srevet_.Constant.PORT;

public class Srevet {
    //4定义一个集合容器存储所有登录进来的客户端管道
       //map集合  键为管道  值为名称
     public static  final Map<Socket,String> onLineSockets=new HashMap<>() ;

    public static void main(String[] args) {

        System.out.println("服务端启动");
        //1注册端口

            try {
                ServerSocket Serversocket=new ServerSocket(PORT);
                while (true) {

                    //等待连接
                    Socket socket=Serversocket.accept();
                    System.out.println(  socket.getInetAddress().getHostAddress()+ "用户连接");
                    //3管道交给线程处理
                     new ServerReader(socket).start();

                }
                //5

            } catch (Exception e) {
               e.printStackTrace();
            }

    }
}
